﻿namespace RuoVea.WeighIns.Server.Models;

/// <summary>
/// 用户个人设置模型
/// </summary>
[SugarTable(nameof(InsUserSettings), "用户个人设置表")]
public class InsUserSettings : EntityBaseId
{
    /// <summary>
    /// 用户ID
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "用户ID", IsNullable = false)]
    public long UserId { get; set; }

    /// <summary>
    /// 身高(cm)
    /// </summary>
    [SugarColumn(ColumnDescription = "身高(cm)", IsNullable = true)]
    public double? Height { get; set; }

    /// <summary>
    /// 性别(1-男, 2-女)
    /// </summary>
    [SugarColumn(ColumnDescription = "性别(1-男, 2-女)", IsNullable = true)]
    public int? Gender { get; set; }

    /// <summary>
    /// 出生日期(用于计算年龄)
    /// </summary>
    [SugarColumn(ColumnDescription = "出生日期", IsNullable = true)]
    public DateTime? BirthDate { get; set; }

    /// <summary>
    /// 单位系统(1-公制kg/cm, 2-英制lb/inch)
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "单位系统(1-公制, 2-英制)", IsNullable = false)]
    public int? UnitSystem { get; set; } = 1;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 健康目标(1-减重, 2-增重, 3-维持, 4-增肌)
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "健康目标", IsNullable = false)]
    public int? HealthGoal { get; set; } = 3;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 每周目标变化量(kg)
    /// </summary>
    [SugarColumn(ColumnDescription = "每周目标变化量(kg)", IsNullable = false)]
    public double? WeeklyGoal { get; set; } = 0.5;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 活动水平(1-5)
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "活动水平(1-5)", IsNullable = false)]
    public int? ActivityLevel { get; set; } = 3;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 每日提醒时间
    /// </summary>
    [SugarColumn(ColumnDescription = "每日提醒时间", IsNullable = true)]
    public TimeSpan? ReminderTime { get; set; }

    /// <summary>
    /// 是否启用提醒
    /// </summary>
    [SugarColumn(ColumnDescription = "是否启用提醒", IsNullable = false)]
    public bool EnableReminder { get; set; } = false;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 接收周报
    /// </summary>
    [SugarColumn(ColumnDescription = "接收周报", IsNullable = false)]
    public bool ReceiveWeeklyReport { get; set; } = true;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 接收趋势提醒
    /// </summary>
    [SugarColumn(ColumnDescription = "接收趋势提醒", IsNullable = false)]
    public bool ReceiveTrendAlerts { get; set; } = true;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 数据分享设置(0-不分享, 1-匿名分享, 2-公开分享)
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "数据分享设置", IsNullable = false)]
    public int? DataSharing { get; set; } = 0;  // 使用属性初始化替代DefaultValue

    /// <summary>
    /// 计算属性：年龄
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public int? Age => BirthDate.HasValue
        ? DateTime.Now.Year - BirthDate.Value.Year
        : null;
}
